package kgame5.kgui.gameui.ringpane {
import kgame5.kutil.KEvent;
import kgame5.kutil.Util;

import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.net.URLRequest;

/**
 * @author kangkai
 */
public class RingCard extends EventDispatcher{
	public static const EVENTTYPE_CLICK:String="EVENTTYPE_CLICK";
	//装大头像的容器,坐标原点是中心，他加载一个loader来实现操作，
	private var 
		mc:MovieClip,
			mc_bg:MovieClip;
	//1,2
	// 0
	public var posiFlag:int;//自己的位置，这个是会变的
	
	private var ID;
	
	public function RingCard(p_ID:int,sFileUrl:String,sLinkID:String){
		mc=Util.AttachMC(sLinkID);
		mc_bg=mc.mc_bg;
		
		ID=p_ID;
		
		var x:int=-mc.width/2;
		var y:int=-mc.height/2;
		
		var l:Loader=new Loader();
		mc.addChild(l);
		l.load(new URLRequest(sFileUrl));
		l.x=x;
		l.y=y;
		
		markFocus(false);
		
		mc.addEventListener(MouseEvent.CLICK, onClick);
	}
	
	public function getMC():MovieClip{
		return mc;
	}
	public function getID():int{
		return ID;
	}
	//标记这个是不是被选中的焦点
	public function markFocus(b:Boolean){
		if(b){//被选中
			mc_bg.gotoAndStop(1);
		}else{//不是被选中的
			mc_bg.gotoAndStop(2);
		}
	}
	
	private function onClick(e:MouseEvent){
		this.dispatchEvent(new KEvent(EVENTTYPE_CLICK));
	}
}//end of class
}
